<template>
	<div class="wrapper">
		<!-- 头部 -->
		<header>
			<div class="icon-location-box">
				<div class="icon-location"></div>
			</div>
			<div class="location-text">
				沈阳龙之梦大厦 <i class="fa fa-caret-down"></i>
			</div>
		</header>

		<!-- search块 -->

		<div class="search">
			<div class="search-fixed-top" ref="fixedBox">
				<div class="search-box">
					<i class="fa fa-search"></i>搜索饿了么商家、商品名称
				</div>
			</div>
		</div>

		<!-- 点餐分类菜单 -->
		<ul class="foodtype">
			<li @click="toBusinessList(1)">
				<img src="../assets/dcfl01.png">
				<p>美食</p>
			</li>
			<li @click="toBusinessList(2)">
				<img src="../assets/dcfl02.png">
				<p>早餐</p>
			</li>
			<li @click="toBusinessList(3)">
				<img src="../assets/dcfl03.png">
				<p>跑腿代购</p>
			</li>
			<li @click="toBusinessList(4)">
				<img src="../assets/dcfl04.png">
				<p>汉堡披萨</p>
			</li>
			<li @click="toBusinessList(5)">
				<img src="../assets/dcfl05.png">
				<p>甜品饮品</p>
			</li>
			<li @click="toBusinessList(6)">
				<img src="../assets/dcfl06.png">
				<p>速食简餐</p>
			</li>
			<li @click="toBusinessList(7)">
				<img src="../assets/dcfl07.png">
				<p>地方小吃</p>
			</li>
			<li @click="toBusinessList(8)">
				<img src="../assets/dcfl08.png">
				<p>包子粥铺</p>
			</li>
			<li @click="toBusinessList(9)">
				<img src="../assets/dcfl09.png">
				<p>地方小吃</p>
			</li>
			<li @click="toBusinessList(10)">
				<img src="../assets/dcfl10.png">
				<p>炸鸡炸串</p>
			</li>
		</ul>

		<!-- 横幅广告 -->
		<div class="banner">
			<h3>品质套餐</h3>
			<p>搭配齐全吃的好</p>
			<a href="#">立即抢购 &nbsp;&gt;</a>
		</div>

		<!-- 超级会员 -->
		<div class="supermember">
			<div class="left">
				<img src="../assets/super_member.png">
				<h3>超级会员</h3>
				<p>&#8226; 每月享超值权益</p>
			</div>
			<div class="right">
				立即开通 &nbsp;&gt;
			</div>
		</div>

		<!-- 推荐商家 -->
		<div class="recommend">
			<div class="recommend-line"></div>
			<p>推荐商家</p>
			<div class="recommend-line"></div>

		</div>

		<!-- 推荐方式 -->
		<ul class="recommendtype">
			<li>综合排序 <i class="fa fa-caret-down"></i></li>
			<li>距离最近</li>
			<li>销量最高</li>
			<li>筛选 <i class="fa fa-filter"></i></li>
		</ul>

		<!-- 商家列表 -->
		<ul class="business">
			<!-- 第1个li -->
			<li>
				<img src="../assets/sj01.png">
				<div class="business-info">
					<div class="business-info-h">
						<h3>万家饺子(软件园E18店)</h3>
						<div>&#8226;</div>
					</div>
					<div class="business-info-star">
						<div class="business-info-star-left">
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star-half"></i>
							<p>4.5 &nbsp;月售345单</p>
						</div>
						<div class="business-info-star-right">
							蜂鸟专送
						</div>
					</div>
					<div class="business-info-delivery">
						<p>&#165; 15起送 | &#165; 3配送</p>
						<p>3.22Km | 30分钟</p>
					</div>
					<div class="business-info-explain">
						<div>各种饺子</div>
					</div>

					<div class="business-info-promotion">
						<div class="business-info-promotion-left">
							<div class="business-info-promotion-left-icon">新</div>
							<p>饿了么新用户首单立减9元</p>
						</div>
						<div class="business-info-promotion-right">
							<p>3个活动 <i class="fa fa-caret-down"></i></p>

						</div>
					</div>

					<div class="business-info-promotion">
						<div class="business-info-promotion-left">
							<div class="business-info-promotion-left-icon" style="background-color: orange;">特</div>
							<p>特价商品5元起</p>
						</div>
					</div>
				</div>
			</li>
			<!-- 第2个li -->
			<li>
				<img src="../assets/sj02.png">
				<div class="business-info">
					<div class="business-info-h">
						<h3>小锅饭豆腐馆(全运店)</h3>
						<div>&#8226;</div>
					</div>
					<div class="business-info-star">
						<div class="business-info-star-left">
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star-half"></i>
							<p>4.5 &nbsp;月售345单</p>
						</div>
						<div class="business-info-star-right">
							蜂鸟专送
						</div>
					</div>
					<div class="business-info-delivery">
						<p>&#165; 15起送 | &#165; 3配送</p>
						<p>3.22Km | 30分钟</p>
					</div>
					<div class="business-info-explain">
						<div>各种饺子</div>
					</div>

					<div class="business-info-promotion">
						<div class="business-info-promotion-left">
							<div class="business-info-promotion-left-icon">新</div>
							<p>饿了么新用户首单立减9元</p>
						</div>
						<div class="business-info-promotion-right">
							<p>3个活动 <i class="fa fa-caret-down"></i></p>

						</div>
					</div>

					<div class="business-info-promotion">
						<div class="business-info-promotion-left">
							<div class="business-info-promotion-left-icon" style="background-color: orange;">特</div>
							<p>特价商品5元起</p>
						</div>
					</div>
				</div>
			</li>
			<!-- 第3个li -->
			<li>
				<img src="../assets/sj03.png">
				<div class="business-info">
					<div class="business-info-h">
						<h3>麦当劳麦乐送(全运路店)</h3>
						<div>&#8226;</div>
					</div>
					<div class="business-info-star">
						<div class="business-info-star-left">
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star-half"></i>
							<p>4.5 &nbsp;月售345单</p>
						</div>
						<div class="business-info-star-right">
							蜂鸟专送
						</div>
					</div>
					<div class="business-info-delivery">
						<p>&#165; 15起送 | &#165; 3配送</p>
						<p>3.22Km | 30分钟</p>
					</div>
					<div class="business-info-explain">
						<div>各种饺子</div>
					</div>

					<div class="business-info-promotion">
						<div class="business-info-promotion-left">
							<div class="business-info-promotion-left-icon">新</div>
							<p>饿了么新用户首单立减9元</p>
						</div>
						<div class="business-info-promotion-right">
							<p>3个活动 <i class="fa fa-caret-down"></i></p>

						</div>
					</div>

					<div class="business-info-promotion">
						<div class="business-info-promotion-left">
							<div class="business-info-promotion-left-icon" style="background-color: orange;">特</div>
							<p>特价商品5元起</p>
						</div>
					</div>
				</div>
			</li>
			<!-- 第4个li -->
			<li>
				<img src="../assets/sj04.png">
				<div class="business-info">
					<div class="business-info-h">
						<h3>米村拌饭(浑南店)</h3>
						<div>&#8226;</div>
					</div>
					<div class="business-info-star">
						<div class="business-info-star-left">
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star-half"></i>
							<p>4.5 &nbsp;月售345单</p>
						</div>
						<div class="business-info-star-right">
							蜂鸟专送
						</div>
					</div>
					<div class="business-info-delivery">
						<p>&#165; 15起送 | &#165; 3配送</p>
						<p>3.22Km | 30分钟</p>
					</div>
					<div class="business-info-explain">
						<div>各种饺子</div>
					</div>

					<div class="business-info-promotion">
						<div class="business-info-promotion-left">
							<div class="business-info-promotion-left-icon">新</div>
							<p>饿了么新用户首单立减9元</p>
						</div>
						<div class="business-info-promotion-right">
							<p>3个活动 <i class="fa fa-caret-down"></i></p>

						</div>
					</div>

					<div class="business-info-promotion">
						<div class="business-info-promotion-left">
							<div class="business-info-promotion-left-icon" style="background-color: orange;">特</div>
							<p>特价商品5元起</p>
						</div>
					</div>
				</div>
			</li>
			<!-- 第5个li -->
			<li>
				<img src="../assets/sj05.png">
				<div class="business-info">
					<div class="business-info-h">
						<h3>申记串道(中海康城店)</h3>
						<div>&#8226;</div>
					</div>
					<div class="business-info-star">
						<div class="business-info-star-left">
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star-half"></i>
							<p>4.5 &nbsp;月售345单</p>
						</div>
						<div class="business-info-star-right">
							蜂鸟专送
						</div>
					</div>
					<div class="business-info-delivery">
						<p>&#165; 15起送 | &#165; 3配送</p>
						<p>3.22Km | 30分钟</p>
					</div>
					<div class="business-info-explain">
						<div>各种饺子</div>
					</div>

					<div class="business-info-promotion">
						<div class="business-info-promotion-left">
							<div class="business-info-promotion-left-icon">新</div>
							<p>饿了么新用户首单立减9元</p>
						</div>
						<div class="business-info-promotion-right">
							<p>3个活动 <i class="fa fa-caret-down"></i></p>

						</div>
					</div>

					<div class="business-info-promotion">
						<div class="business-info-promotion-left">
							<div class="business-info-promotion-left-icon" style="background-color: orange;">特</div>
							<p>特价商品5元起</p>
						</div>
					</div>
				</div>
			</li>
			<!-- 第6个li -->
			<li>
				<img src="../assets/sj06.png">
				<div class="business-info">
					<div class="business-info-h">
						<h3>半亩良田排骨米饭</h3>
						<div>&#8226;</div>
					</div>
					<div class="business-info-star">
						<div class="business-info-star-left">
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star"></i>
							<i class="fa fa-star-half"></i>
							<p>4.5 &nbsp;月售345单</p>
						</div>
						<div class="business-info-star-right">
							蜂鸟专送
						</div>
					</div>
					<div class="business-info-delivery">
						<p>&#165; 15起送 | &#165; 3配送</p>
						<p>3.22Km | 30分钟</p>
					</div>
					<div class="business-info-explain">
						<div>各种饺子</div>
					</div>

					<div class="business-info-promotion">
						<div class="business-info-promotion-left">
							<div class="business-info-promotion-left-icon">新</div>
							<p>饿了么新用户首单立减9元</p>
						</div>
						<div class="business-info-promotion-right">
							<p>3个活动 <i class="fa fa-caret-down"></i></p>

						</div>
					</div>

					<div class="business-info-promotion">
						<div class="business-info-promotion-left">
							<div class="business-info-promotion-left-icon" style="background-color: orange;">特</div>
							<p>特价商品5元起</p>
						</div>
					</div>
				</div>
			</li>
		</ul>
		
		<!-- 添加Footer组件 -->
		<Footer></Footer>
	</div>
</template>

<script>
	//导入共通组件
	import Footer from '../components/Footer.vue'
	
	export default{
		name:'Index',
		mounted() { //挂载方法 ,页面dom元素都加载完毕后执行 . 
			//因为要操作dom元素,所以需要dom挂载之后,才能找到document中的属性
			document.onscroll= ()=>{
				var s1 = document.documentElement.scrollTop;
				var s2 = document.body.scrollTop;
				var deviceWidth = document.documentElement.clientWidth;
				var scroll = (s1==0)?s2:s1; //滚动条位置
				var search = this.$refs.fixedBox;
				if(scroll>=deviceWidth*0.12){
					search.style.position='fixed';
					search.style.left=0;
					search.style.top=0;
				}else{
					search.style.position='static';
				}
			}
		},
		destroyed() {
			//当切换组件时,不需要在有滚动条事件,所以置为null
			document.onscroll = null;
		},
		components:{
			Footer
		},
		methods:{
			toBusinessList(orderTypeId){
				this.$router.push({path:'/businessList',query:{orderTypeId:orderTypeId}})
			}
		}
	}
	
</script>

<!-- 添加了scoped属性, 其中的样式只作用于当前的组件,其他组件不受影响 -->
<style scoped>
	/* wrapper  总容器*/
	.wrapper {
		width: 100%;
		height: 100%;
	}

	/* header 容器 */
	.wrapper header {
		width: 100%;
		height: 12vw;
		background-color: #0097FF;
		display: flex;
		align-items: center;
	}

	.wrapper header .icon-location-box {
		width: 3.5vw;
		height: 3.5vw;
		margin: 0 1vw 0 3vw;
	}

	.wrapper header .location-text {
		color: #fff;
		font-size: 4.5vw;
		font-weight: 700;
	}

	.wrapper header .location-text .fa-caret-down {
		margin-left: 1vw;
	}

	/* search容器 */
	.wrapper .search {
		width: 100%;
		height: 13vw;
	}

	.wrapper .search .search-fixed-top {
		width: 100%;
		height: 13vw;
		background-color: #0097FF;

		display: flex;
		justify-content: center;
		align-items: center;
	}

	.wrapper .search .search-fixed-top .search-box {
		background-color: #fff;
		width: 90%;
		height: 9vw;
		border-radius: 2px;

		display: flex;
		justify-content: center;
		align-items: center;

		font-size: 3.5vw;
		color: #AEAEAE;
		font-family: "宋体";

		user-select: none;
		/*文本选中状态无效*/
	}

	.wrapper .search .search-fixed-top .search-box .fa-search {
		margin-right: 1vw;
	}

	/* 点餐菜单 */
	.wrapper .foodtype {
		width: 100%;
		height: 48vw;

		display: flex;
		flex-wrap: wrap;
		align-content: center;
		justify-content: space-around;
	}

	.wrapper .foodtype li {
		width: 18vw;
		height: 20vw;

		/* 通过这块设置li中的图片和文字样式 */
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}

	.wrapper .foodtype li img {
		width: 12vw;
		height: 10.3vw;
	}

	.wrapper .foodtype li p {
		font-size: 3.2vw;
		color: #666;
	}

	/* 横幅广告位 */
	.wrapper .banner {
		width: 95%;
		margin: 0 auto;
		height: 29vw;

		background-image: url(../assets/index_banner.png);
		background-repeat: no-repeat;
		background-size: cover;

		box-sizing: border-box;
		padding: 2vw 6vw;
	}

	.wrapper .banner h3 {
		margin-top: 1.2vw;
		font-size: 4.2vw;
		margin-bottom: 1.2vw;
	}

	.wrapper .banner p {
		font-size: 3.4vw;
		color: #AEAEAE;
		margin-bottom: 2.4vw;
	}

	.wrapper .banner a {
		font-size: 3vw;
		color: #c79060;
	}

	/* 超级会员 */
	.wrapper .supermember {
		width: 95%;
		margin: 0 auto;
		height: 11.5vw;
		background-color: #feedc1;
		color: #644f1b;
		margin-top: 1.3vw;
		border-radius: 2px;
		box-sizing: border-box;
		padding: 0 4vw;

		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.wrapper .supermember .left {
		display: flex;
		align-items: center;
	}

	.wrapper .supermember .left img {
		width: 6vw;
		height: 6vw;
		margin-right: 2vw;
	}

	.wrapper .supermember .left h3 {
		font-size: 4vw;
		margin-right: 2vw;
	}

	.wrapper .supermember .left p {
		font-size: 3vw;
	}

	.wrapper .supermember .right {
		font-size: 3vw;
		cursor: pointer;
	}

	/* 推荐商家 */
	.wrapper .recommend {
		width: 100%;
		height: 14vw;

		display: flex;
		justify-content: center;
		align-items: center;
	}

	.wrapper .recommend .recommend-line {
		width: 6vw;
		height: 0.3vw;
		background-color: #888;
	}

	.wrapper .recommend p {
		font-size: 4vw;
		margin: 0 4vw;
	}

	/* 推荐方式 */
	.wrapper .recommendtype {
		width: 100%;
		height: 5vw;
		margin-bottom: 5vw;

		display: flex;
		justify-content: space-around;
		align-items: center;
	}

	.wrapper .recommendtype li {
		font-size: 3.5vw;
		color: #555;
	}

	/* 商家列表 */
	.wrapper .business {
		width: 100%;
		padding-bottom: 14vw;
		/* 为了让底部菜单不遮挡商家列表,特意加的
	 由margin-bottom 改为 padding-bottom ,浏览器兼容
	 */
	}

	.wrapper .business li {
		width: 100%;

		display: flex;
		box-sizing: border-box;
		padding: 2vw;
		border-bottom: 1px solid #DDD;

	}

	.wrapper .business li img {
		width: 18vw;
		height: 18vw;
	}

	.wrapper .business .business-info {
		padding-left: 3vw;
		box-sizing: border-box;
		width: 100%;
	}

	.wrapper .business .business-info .business-info-h {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 2vw;
	}

	.wrapper .business .business-info .business-info-h h3 {
		font-size: 4vw;
		color: #333;
	}

	.wrapper .business .business-info .business-info-h div {
		width: 1.6vw;
		height: 3.4vw;
		background-color: #666;
		color: #fff;
		font-size: 4vw;
		margin-right: 4vw;

		/* 解决圆点居中 */
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.wrapper .business .business-info .business-info-star {
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 2vw;
		font-size: 3.1vw;
	}

	.wrapper .business .business-info .business-info-star .business-info-star-left {
		display: flex;
		align-items: center;
	}

	.wrapper .business .business-info .business-info-star .business-info-star-left .fa-star {
		color: #FEC80E;
		margin-right: 0.5vw;
	}

	.wrapper .business .business-info .business-info-star .business-info-star-left .fa-star-half {
		color: #FEC80E;
		margin-right: 0.5vw;
	}

	.wrapper .business .business-info .business-info-star .business-info-star-left p {
		margin-left: 2vw;
		color: #666;
	}

	.wrapper .business .business-info .business-info-star .business-info-star-right {
		background-color: #0097FF;
		color: #fff;
		border-radius: 2px;
		padding: 0 0.5vw;
	}

	.wrapper .business .business-info .business-info-delivery {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 2vw;
		color: #666;
		font-size: 3.1vw;
	}

	.wrapper .business .business-info .business-info-explain {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 2vw;
	}

	.wrapper .business .business-info .business-info-explain div {
		color: #666;
		font-size: 2.8vw;
		border: 1px solid #ddd;
		border-radius: 2px;
		padding: 0 0.5vw;
	}

	.wrapper .business .business-info .business-info-promotion {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 2vw;
	}

	.wrapper .business .business-info .business-info-promotion .business-info-promotion-left {
		display: flex;
		align-items: center;
	}

	.wrapper .business .business-info .business-info-promotion .business-info-promotion-right {
		display: flex;
		align-items: center;
	}

	.wrapper .business .business-info .business-info-promotion .business-info-promotion-left .business-info-promotion-left-icon {
		width: 4vw;
		height: 4vw;
		background-color: #70BC46;
		border-radius: 2px;

		display: flex;
		justify-content: center;
		align-items: center;

		color: #fff;
		font-size: 3vw;
	}

	.wrapper .business .business-info .business-info-promotion .business-info-promotion-left p {
		color: #666;
		font-size: 3vw;
		margin-left: 2vw;
	}

	.wrapper .business .business-info .business-info-promotion .business-info-promotion-right p {
		color: #666;
		font-size: 3vw;
		margin-left: 2vw;
	}


</style>
